package com.lxj.controller;

import com.lxj.domain.University;
import com.lxj.service.UniversityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@ResponseBody
@RequestMapping("/university")
public class UniversityController {
    @Autowired
    private UniversityService universityService;

    @PostMapping("/selectAll")
    public Map<String, Object> selectAll(University university) {
        List<University> list = universityService.selectAll(university);
        int number = universityService.getNumber();
        Map<String,Object> map = new HashMap<>();
        map.put("list",list);
        map.put("number",number);
        return map;
    }
    @GetMapping("/delete")
    public int delete(Integer[] id){
        return universityService.delete(id);
    }
    @GetMapping("/add")
    public int add(University university){
        return universityService.add(university);
    }
    @PostMapping("/findById")
     public University findById(Integer id){
        return universityService.findById(id);
    }
    @PostMapping("/edit")
    public int edit(University university){
        return universityService.edit(university);
    }
}
